package com.home.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.home.dao.addDao;

public class consumptionServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int consumption=Integer.parseInt(request.getParameter("cprice"));
		String name=request.getParameter("name");
		String remark=request.getParameter("ramark");
		com.home.entity.consumption c=new com.home.entity.consumption();
		c.setCname(name);
		c.setCprice(consumption);
		c.setCremark(remark);
		addDao ad=new addDao();
		boolean boo= ad.addConsumption(c);
		if(boo){
			response.sendRedirect("lifemManage/imf.jsp");
		}else{
			response.sendRedirect("lifemManage/addImf.jsp");
		}
	}

}
